import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.junit.Test;

import java.io.IOException;
import java.net.URL;
import java.util.regex.Pattern;

/**
 * @author honway.liu
 * @date 2017/8/28 下午10:40
 * @email gm100861@gmail.com
 * @blog http://linuxsogood.org
 */
public class DemoHttp {

    public static void main(String[] args) throws IOException {
        OkHttpClient okHttpClient = new OkHttpClient();
        Request request = new Request.Builder().url(new URL("http://news.163.com/17/0828/22/CSV6SA3T000189FH.html")).build();
        Response response = okHttpClient.newCall(request).execute();
        if (response.isSuccessful()) {
            String responseBody = response.body().string();
            Document document = Jsoup.parse(responseBody);
            Elements title = document.select("#epContentLeft>h1");
            System.out.println(title.text());
        }
    }

    @Test
    public void method1() {

        System.out.println(isNumeric("+5"));
        System.out.println(isNumeric("-5.2"));
        System.out.println(isNumeric("05"));
        String s = "005.2";
        Double d = Double.valueOf(s);
        System.out.println(d);
    }

    public static boolean isNumeric(String str){
        Pattern pattern = Pattern.compile("^[+|-]?[0-9][.]?[0-9]*");
        return pattern.matcher(str).matches();
    }
}
